<template>
	<div class="songslist">
		<!-- 头部 -->
		<div class="head">
			<span @click="goback"><van-icon name="arrow-left" />返回</span>
			<!-- <span>歌曲</span> -->
			<span><van-icon name="ellipsis"  size="20" /></span>
		</div>
		<!-- 内容 -->
		<van-tabs swipeable @click="choose">
			<van-tab v-for="item in list" :title="item.name" :key="item.id">
				<p class="all">全部{{ item.name }}</p>
				<ul class="songsheets">
					<li
						v-for="item in list2"
						:key="item.id"
						@click="gosongListDetail(item.id)"
					>
						<img :src="item.coverImgUrl" alt="" />
						<p class="songsheetname">{{ item.name }}</p>
						<span class="songsheetplay"
							><van-icon name="play" />{{
								(item.playCount / 10000).toFixed(1) + "万"
							}}</span
						>
					</li>
				</ul>
			</van-tab>
		</van-tabs>
	</div>
</template>

<script>
import { songslistAPI, songslistdetail } from "../../api/song";
export default {
	data() {
		return {
			list: [],
			list2: [],
		};
	},
	computed: {},
	watch: {},

	methods: {
        //返回上一页
        goback(){
            this.$router.go(-1);
        },
		//显示精品歌单分类
		async showSongsList() {
			const result = await songslistAPI();
			console.log(result);
			if (result.data.code == 200) {
				this.list = result.data.tags;
				console.log(111, this.list);
			}
		},
		//选中那个分类，显示分类的具体详情
		async choose(name = 0, title = "华语") {
			console.log(name, title);
			const result = await songslistdetail(title);
			console.log(result);
			if (result.data.code == 200) {
				this.list2 = result.data.playlists;
				console.log(222, this.list2);
			}
		},
		gosongListDetail(id) {
			this.$router.push(`/songlistdetail/${id}`);
		},
	},
	created() {
		this.showSongsList();
		this.choose();
	},
	mounted() {},
	components: {},
};
</script>
<style scoped>
.head {
	display: flex;
	justify-content: space-between;
     align-items: center;
	height: 50px;
	background: #fff;
	padding: 0 10px;
	box-sizing: border-box;
}
.all {
	font-size: 18px;
	margin: 15px 0 0 15px;
}
.songsheets {
	width: 100%;
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-start;
}
.songsheets li {
	display: inline-block;
	width: 30%;
	margin-top: 10px;
	margin-left: 2.5%;
	padding-bottom: 10px;
	position: relative;
}
.songsheets img {
	width: 100%;
	border-radius: 20px;
	border: 1px solid #ccc;
}
.songsheetname {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
	width: 100%;
	margin-top: 3px;
}
.songsheetplay {
	display: inline-block;
	box-sizing: border-box;
	padding: 1px 8px 2px 4px;
	background-color: rgba(0, 0, 0, 0.329);
	border-radius: 20px;
	color: #fff;
	position: absolute;
	top: 8px;
	right: 5px;
	font-size: 14px;
}
</style>
